include ../Makefile.config

CXXINCLUDES = ${INCLUDES} ${MPIINCLUDE}

FILEDIRS =\
 ${CURDIR}/../base\
 ${CURDIR}/../matrix\
 ${CURDIR}/../matrix/csrMatrix\
 ${CURDIR}\
 ${CURDIR}/PBiCGStab\
 ${CURDIR}/preconditioners\
 ${CURDIR}/solverPerformance\
 ${CURDIR}/Multigrid\
 ${CURDIR}/Multigrid/smoothers\
 ${CURDIR}/Multigrid/aggregation\

CXX_COMPILE_FLAGS =\
 $(patsubst %,-I%,$(FILEDIRS)) \
 ${CINCLUDES}

HEADERS=$(foreach dir, $(FILEDIRS) , $(wildcard $(dir)/*.hpp) $(wildcard $(dir)/*.h))


FILES =\
    unapMatrixSolver.cpp \
    solverPerformance/solverPerformance.cpp \
    Multigrid/smoothers/relaxedJacobiSmoother.cpp \
    Multigrid/Multigrid.cpp \
    Multigrid/aggregation/pmisAggregation.cpp \
    Multigrid/aggregation/aggregation.cpp \
    preconditioners/unapPreconditioner.cpp \
    preconditioners/DiagPrecond.cpp \
    preconditioners/DILUPrecond.cpp \
    preconditioners/csrDILUPrecond.cpp \
    preconditioners/MGPrecond.cpp \
    PBiCGStab/PBiCGStab.cpp \
    solverFactory.cpp 



COBJS = ${FILES:.cpp=.o}
OBJS = ${COBJS}

SONAME = libUNAP_solvers-${LIB_SUFFIX}

##################################################################
# Targets
##################################################################

all: libUNAP_solvers${LIB_SUFFIX}

install: libUNAP_solvers${LIB_SUFFIX}

clean:
	rm -f ${OBJS}
	rm -f *.o *.obj libUNAP*

distclean: clean

##################################################################
# Rules
##################################################################

libUNAP_solvers.a: ${OBJS}
	@echo  "Building $@ ... "
	${AR} $@ ${OBJS}
	${RANLIB} $@
	cp ${HEADERS} ${INSTALL_DIR}/include

libUNAP_solvers.so libUNAP_solvers.dylib: ${OBJS}
	@echo  "Building $@ ... "
	${BUILD_CC_SHARED} -o ${SONAME} ${OBJS} ${SHARED_SET_SONAME}${SONAME}
	ln -s -f ${SONAME} $@
	cp ${HEADERS} ${INSTALL_DIR}/include
